package band.wukong.practice.javase.core.io.standardio;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

/**
 * Desc: 包装System.in。console等待用户输入数据后echo
 * Author: sunjs
 * Date: 2009-11-17 11:20:33
 */
public class TestWrappedSystemIn {
    public static void main(String[] args) throws Exception {
        testWrappedSystemIn();
    }


    /**
     * 包装System.in
     *
     * @throws Exception
     */
    public static void testWrappedSystemIn() throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        PrintWriter pw = new PrintWriter(System.out, true);//true代表是否自动刷新，如不填，有可能看不到输出
        String data;
        while (null != (data = br.readLine()) && data.length() != 0) {
//            System.out.println("echo = " + data);
            pw.println("echo = " + data);
        }
        //TODO [Bug]System.in不支持中文???
    }

}
